package com.qianying.controller.admin;

import com.qianying.comment.CommonResult;
import com.qianying.dto.DeleteRequestByIdDTO;
import com.qianying.dto.OrderDTO;
import com.qianying.dto.OrderGetDataRequestDTO;
import com.qianying.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping(value="/pub/order/", produces ="application/json;charset=utf-8")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping(value = "saveData")
    public CommonResult<Object> saveData(@RequestBody OrderDTO param) {
        return CommonResult.success(orderService.saveData(param), "保存数据成功");
    }

    @PostMapping("deleteData")
    public CommonResult<Object> deleteData(@Valid @RequestBody DeleteRequestByIdDTO param ) {
        return CommonResult.success(orderService.deleteData(param), "删除数据成功");
    }

    @PostMapping(value = "getData")
    public CommonResult<Object> getData(@RequestBody OrderGetDataRequestDTO param) {
        return CommonResult.success(orderService.getData(param), "获取数据成功");
    }


//    @DeleteMapping("/deleteData/{id}")
//    public CommonResult<Integer> deleteData(@PathVariable Long id) {
//        return CommonResult.success(orderService.deleteData(id), "删除数据成功");
//    }

}